//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.middlegroup.subjectpay.service.ucfpay;

import java.util.Calendar;
import java.util.UUID;

public class UnRepeatCodeGenerator {
    public UnRepeatCodeGenerator() {
    }

    public static String createUnRepeatCode(String merchantId, String service, String merchantNo) throws CoderException {
        if(merchantId != null && !"".equals(merchantId)) {
            if(service != null && !"".equals(service)) {
                if(merchantNo == null || "".equals(merchantNo)) {
                    merchantNo = String.valueOf(Calendar.getInstance().getTimeInMillis());
                }

                StringBuilder strBuffer = new StringBuilder();
                String randomVal = UUID.randomUUID().toString();
                strBuffer.append(merchantId).append(service).append(merchantNo).append(randomVal);
                String reqSn = UcfDigestUtils.digestMD5(strBuffer.toString());
                if(!"".equals(reqSn) && reqSn != null) {
                    return reqSn;
                } else {
                    throw new CoderException("获取reqSn失败，请重试");
                }
            } else {
                throw new CoderException("service:请求的服务名称不能为空");
            }
        } else {
            throw new CoderException("merchantId:商户号不能为空");
        }
    }

    public static void main(String[] args) {
        try {
            System.out.println(createUnRepeatCode("1111", "2222", "3333"));
        } catch (CoderException var2) {
            var2.printStackTrace();
        }

    }
}
